package com.quectel.constant.core.forum;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/5/15 17:35
 * @description new java file header...
 */
public class ForumConstants {
    /**
     * PNG、JPG、JPEG、BMP、GIF
     */

    public static final Set<String> IMG_ACCEPT_TYPE = new HashSet<>(Arrays.asList("image/png", "image/jpeg", "image/bmp"));

    public static final Pair<String, String> PUBLISH_TIME_SLOT_KEY_PAIR = ImmutablePair.of("publishStartTime", "publishEndTime");
    public static final Pair<String, String> AUDIT_TIME_SLOT_KEY_PAIR = ImmutablePair.of("auditStartTime", "auditEndTime");


    public static final String TOPICS = "topics";
    public static final String CURRENT_USER = "currentUser";
    public static final String MSG_TYPES = "msgTypes";

    public static final String SENSITIVE_WORD_CACHE = "SENSITIVE_WORD_CACHE:";

    @AllArgsConstructor
    public enum ForumAuditResultEnum {
        /**
         * 删除帖子
         */
        DELETE_POST((byte) 1),

        /**
         * 删除评论
         */
        DELETE_COMMENT((byte) 2),

        /**
         * 禁言用户
         */
        MUTE((byte) 3),
        ;

        @Getter
        @Setter
        private Byte result;

    }

    /**
     * 审核对象
     */
    @AllArgsConstructor
    public enum ForumAuditObjectEnum {
        /**
         * 帖子
         */
        POST((byte) 1),

        /**
         * 评论
         */
        COMMENT((byte) 2),
        ;

        @Getter
        @Setter
        private Byte type;

    }







    /**
     * 推送类型
     */
    @AllArgsConstructor
    public enum ForumRange {
        /**
         * 小区
         */
        VILLAGE((byte) 1),

        /**
         * 同城
         */
        CITY((byte) 2),

        /**
         * 全国
         */
        ALL((byte) 3),

        ;

        @Getter
        @Setter
        private Byte range;


    }

    /**
     * 推送类型
     */
    @AllArgsConstructor
    public enum ForumHandleType {
        /**
         * 发帖
         */
        POST((byte) 1, "post"),

        /**
         * 评论
         */
        POST_COMMENT((byte) 2, "comment"),

        /**
         * 点赞
         */
        LIKE((byte) 3, "like"),

        /**
         * 分享
         */
        SHARE((byte) 4, "share"),


        /**
         * 评论点赞
         */
        LIKE_COMMENT((byte) 5, "like"),

        /**
         * 评论的评论
         */
        COMMENT_COMMENT((byte) 6, "comment"),

        ;

        @Getter
        @Setter
        private Byte type;
        @Getter
        @Setter
        private String fieldName;

        public static ForumConstants.ForumHandleType getByType(Byte type) {
            for (ForumConstants.ForumHandleType typeEnum : ForumConstants.ForumHandleType.values()) {
                if (typeEnum.getType().equals(type)) {
                    return typeEnum;
                }
            }
            return null;
        }

    }


}
